#!/bin/bash
#功能：导入ods_hy_car，全量导入
#创建人：王恩宝
#创建日期：2019-06-20

#初始化环境变量
source $(cd "$(dirname "$0")"; pwd)/../../initEnv.sh
table_name=hy_car
target_table_name=ods_hy_car
echo "导入${target_table_name}开始..."

sqoop-import \
  -D mapred.job.queue.name=hive \
  --connect $HY_CONNECT \
  --username $HY_USERNAME \
  --password $HY_PASSWORD \
  --table ${table_name} \
  --fields-terminated-by "\0001" \
  --delete-target-dir \
  --target-dir /user/root/mysql_tables/${table_name} \
  --hive-import \
  --hive-overwrite \
  --hive-table ${target_table_name} \
  --hive-database ${HIVE_DB} \
  --hive-drop-import-delims \
  --num-mappers 1 \
  --as-parquetfile;

#hive --hiveconf "tez.queue.name=hive" -e "load data inpath '/user/root/mysql_tables/${table_name}/*.parquet' OVERWRITE  into table ${HIVE_DB}.${target_table_name}"

if [ $? -ne 0 ] ; then
  echo "导入ods_hy_car失败，耗时$((`date +%s`-START_TIME))秒..."
else
  echo "导入ods_hy_car成功，耗时$((`date +%s`-START_TIME))秒..."
fi
